<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         * 通过捕捉get set 等操作可以监控这个对象在何处何时被访问过
         * */

         const user = {
            name: 'xiaomi'
         }
         const proxy = new Proxy(user, {
            get(target, property, receiver) {
                console.log(`getting${property}`)

                return Reflect.get(...arguments)
            },

            set(target, property, value, receiver) {
                console.log(`setting${property}=${value}`)
            }
         })
         proxy.name
         proxy.name = 'xiaomi'
    </script>
</body>
</html>